package com.zimin.redis.config;

import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

/**
 * @author : guo shi qi
 * @Date: 2019-08-05 17:34
 * @Description:
 */
@Configuration
@Slf4j
public class RedissonConfig {

    @Value("${redisson.config}")
    private String redissonConfig;


    @Bean
    public RedissonClient redissonClient() throws IOException {
        return Redisson.create(
                Config.fromYAML(new ClassPathResource(redissonConfig).getInputStream())
        );
    }
}
